package cn.tedu.micro.demo.device.service;

import cn.tedu.micro.demo.common.pojo.po.GunInfoPO;
import cn.tedu.micro.demo.common.pojo.vo.GunInfoVO;
import cn.tedu.micro.demo.device.repository.GunRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class GunServiceImpl implements GunService{
    @Autowired
    private GunRepository gunRepository;

    @Override
    public GunInfoVO detail(Long gunId) {
        //日志打印的位置 入参
        log.info("查询充电枪详情入参:{}",gunId);
        //1.仓储层 返回值 不能是vo 是po
        GunInfoPO po=gunRepository.getGunById(gunId);
        //2.po  转换成vo
        GunInfoVO vo=null;
        if (po!=null) {
            //日志打印位置 分支
            log.info("查询充电枪详情po:{}",po);
            vo=new GunInfoVO();
            BeanUtils.copyProperties(po, vo);
        }
        //日志打印的位置 出参
        log.info("查询充电枪详情出参:{}",vo);
        return vo;
    }
}
